package pnlRestaurant;

import java.awt.BorderLayout;
import java.awt.Color;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import tblLSListner.TMSLTafel;
import tblModelTafel.TMTafel;
import controllerTaf.TafBtnDelete;
import controllerTaf.TafBtnSave;

public class PnlResMain extends JPanel{

	/**
	 * 
	 */
	private static final long serialVersionUID = -7355447390912782080L;
	
	public JPanel pnlTblTafel;
	public JTable tblTafel;
	public JScrollPane scrollTafel;
	
	public JPanel pnlLeftPanell;
	public JPanel pnlRightPanell;
	public JLabel lblTitleBeheer;
	public JLabel lblTafelNummerR;
	public JLabel lblTafelNummerL;
	public JLabel lblTitleZoeken;
	public JLabel lblSaveMelding;
	public JLabel LblDeleteMelding;
	
	public JTextField txtTafelNummerR;
	public JTextField txtTafelnummerL;
	 
	public ImageIcon imgDelete;
	public ImageIcon imgSave;

	public JButton btnsave;
	public JButton btndelete;
	
	public TafBtnSave ts;
	public TafBtnDelete td;
	public TMTafel tmt;
	
	public TMSLTafel tmsltafel;
	
	public PnlResMain(){
		
		this.tmt = new TMTafel(this);
		
		this.ts = new TafBtnSave(this);
		this.td = new TafBtnDelete(this);
		this.tmsltafel = new TMSLTafel(this);
		
        setBounds(0,0,1365,725);
        setLayout(new BorderLayout());
        setBackground(Color.pink); 
        setLayout(null);
        
	    pnlLeftPanell = new JPanel ();
	    pnlLeftPanell.setBackground(Color.white);
	    pnlLeftPanell.setBounds(75, 50, 400, 250);
	    pnlLeftPanell.setLayout(null);
		pnlLeftPanell.setBorder(BorderFactory.createLineBorder(Color.black));
		add(pnlLeftPanell);
	
		pnlRightPanell = new JPanel ();
		pnlRightPanell.setBackground(Color.white);
		pnlRightPanell.setBounds(850, 50, 400, 250);
		pnlRightPanell.setLayout(null);
		pnlRightPanell.setBorder(BorderFactory.createLineBorder(Color.black));
		add(pnlRightPanell);
        
        
    	lblTitleBeheer = new JLabel("<html><h1><b>Tafel beheer:</b></h1></html>");
		lblTitleBeheer.setBounds(130, 10, 300, 40);
		pnlRightPanell.add(lblTitleBeheer);
		
		lblSaveMelding = new JLabel("Tafel is toegevoegd.");
		lblSaveMelding.setBounds(150, 70, 150, 20);
		lblSaveMelding.setForeground(Color.red);
		lblSaveMelding.setVisible(false);
		pnlRightPanell.add(lblSaveMelding);
		
		LblDeleteMelding = new JLabel("Tafel is verwijderd.");
		LblDeleteMelding.setBounds(150, 70, 150, 20);
		LblDeleteMelding.setForeground(Color.red);
		LblDeleteMelding.setVisible(false);
		pnlRightPanell.add(LblDeleteMelding);

		lblTafelNummerR = new JLabel("Tafelnummer:");
		lblTafelNummerR.setBounds(160, 100, 100, 20);
		pnlRightPanell.add(lblTafelNummerR);
		
		txtTafelNummerR = new JTextField();
		txtTafelNummerR.setBounds(110, 120, 180, 20);
		pnlRightPanell.add(txtTafelNummerR);
		
		lblTitleZoeken = new JLabel("<html><h1><b>Tafel zoeken:</b></h1></html>");
		lblTitleZoeken.setBounds(130, 10, 300, 40);
		pnlLeftPanell.add(lblTitleZoeken);
		
		lblTafelNummerL = new JLabel("Tafelnummer:");
		lblTafelNummerL.setBounds(160, 80, 100, 20);
		pnlLeftPanell.add(lblTafelNummerL);
		
		pnlTblTafel = new JPanel();
		pnlTblTafel.setLayout(new BorderLayout());
		pnlTblTafel.setBounds(850, 350, 400, 300);
		add(pnlTblTafel);
		
		tblTafel = new JTable();
		tblTafel.setBounds(0,0,600,0);
		tblTafel.getSelectionModel().addListSelectionListener(tmsltafel);
		tblTafel.setModel(tmt);
		
		scrollTafel = new JScrollPane(tblTafel);
		pnlTblTafel.add(scrollTafel);
		
		imgSave = new ImageIcon(getClass().getResource("/image/save.gif"));
		btnsave = new JButton("Save",imgSave);
		btnsave.setHorizontalTextPosition(JButton.CENTER);
		btnsave.setVerticalTextPosition(JButton.BOTTOM);
		btnsave.setBounds(100, 150, 100, 90);
		btnsave.setOpaque(false);
		btnsave.setContentAreaFilled(false);
		btnsave.setBorderPainted(false);
		btnsave.setFocusPainted(false);
		btnsave.addActionListener(ts);
		btnsave.setActionCommand("Save");
		pnlRightPanell.add(btnsave);
		
		imgDelete = new ImageIcon(getClass().getResource("/image/trash.gif"));
		btndelete = new JButton("Delete",imgDelete);
		btndelete.setHorizontalTextPosition(JButton.CENTER);
		btndelete.setVerticalTextPosition(JButton.BOTTOM);
		btndelete.setBounds(200, 150, 100, 90);
		btndelete.setOpaque(false);
		btndelete.setContentAreaFilled(false);
		btndelete.setBorderPainted(false);
		btndelete.setFocusPainted(false);
		btndelete.addActionListener(td);
		btndelete.setActionCommand("Delete");		
		pnlRightPanell.add(btndelete);
		
		
		
	}

	public JLabel getLblSaveMelding() {
		return lblSaveMelding;
	}


	public JLabel getLblDeleteMelding() {
		return LblDeleteMelding;
	}



	public JTextField getTxtTafelNummerR() {
		return txtTafelNummerR;
	}


	public JTextField getTxtTafelnummerL() {
		return txtTafelnummerL;
	}
	
	public void setTblTafel(JTable tblTafel) {
		this.tblTafel = tblTafel;
	}
	
	public JTable getTblTafel() {
		return tblTafel;
	}

	
}
